-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Add tests without modifying code #10740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Added doctest to largest_of_very_large_numbers.py Added doctest to word_patterns.py Added doctest to onepad_cipher.py
for more information, see https://pre-commit.ci
Added doctest to maths/largest_of_very_large_numbers.py Added doctest to strings/word_patterns.py Added doctest to ciphers/onepad_cipher.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Different PR !! one PR can't change the entire stuff, so it should be one by one which becomes easy for the maintainers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Just a few changes...
ciphers/onepad_cipher.py
Outdated
Traceback (most recent call last): | ||
... | ||
IndexError: list index out of range | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
>>> res(0, 5) | ||
0 | ||
|
||
>>> res(3, 0) | ||
1 | ||
|
||
>>> res(-1, 5) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: math domain error | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better if the tests do not require extra scrolling when someone is reading the code. If they want to read all the tests, they can take the time to do so but often readers will want to look at the function signature and then jump straight to the code. Keeping the tests in tight block will allow them them to study the function signature and the code without too much visual distraction.
>>> res(0, 5) | |
0 | |
>>> res(3, 0) | |
1 | |
>>> res(-1, 5) | |
Traceback (most recent call last): | |
... | |
ValueError: math domain error | |
>>> res(0, 5) | |
0 | |
>>> res(3, 0) | |
1 | |
>>> res(-1, 5) | |
Traceback (most recent call last): | |
... | |
ValueError: math domain error |
>>> get_word_pattern("") | ||
'' | ||
>>> get_word_pattern(" ") | ||
'0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put the tests that work correctly first and then afterward the ones that raise exceptions.
Also, please add:
>>> get_word_pattern(1)
>>> get_word_pattern(1.1)
>>> get_word_pattern([])
@imSanko You are correct but in this case, adding tests without changing code makes this one easy to review. I can read through the tests and see if they make sense and hit some corner cases. Then I can look at the It would be easier to review is all the algorithms chosen were in the same directory. |
Added test to maths/largest_of_very_large_numbers Added test to strings/word_patterns.py Added test to ciphers/onepad_cipher.py
Ok. Awesome. I went ahead and made the requested format changes and additions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!!
* Contributes to TheAlgorithms#9943 Added doctest to largest_of_very_large_numbers.py Added doctest to word_patterns.py Added doctest to onepad_cipher.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Contributes to TheAlgorithms#9943 Added doctest to maths/largest_of_very_large_numbers.py Added doctest to strings/word_patterns.py Added doctest to ciphers/onepad_cipher.py * Add tests without modifying code TheAlgorithms#10740 Added test to maths/largest_of_very_large_numbers Added test to strings/word_patterns.py Added test to ciphers/onepad_cipher.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Describe your change:
Contributes to #9943
Added doctest to maths/largest_of_very_large_numbers.py
Added doctest to strings/words_patterns.py
Added doctest to ciphers/onepad_cipher.py
Checklist: